FROM golang:1.17-alpine3.15 AS builder

WORKDIR /build

ENV GOPROXY=https://goproxy.cn,direct
COPY go.mod .
COPY go.sum .
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -o hyperway ./main

FROM alpine:3.15 AS final

COPY --from=builder /build/hyperway /app/
COPY --from=builder /build/startup.sh /app/
COPY --from=builder /build/main/conf.d /app/conf.d

WORKDIR /app

RUN chmod +x startup.sh
EXPOSE 6883

CMD ["sh","/app/startup.sh"]